﻿# For on_actions launched by the code itself.

# Root = Country
on_monthly_pulse_country = {
	events = {
		communism.8 # Red Army
		peoples_springtime.1
		opium_wars.1
		# native_resettlement.1
		meiji.13
		#bic_breakup.1
		dvg_sca_finland.10 # Finnish radicals
		dvg_spain.25 #become monarchy for viceroyalties
		dvg_zhourao.6 # The Northern Hui Defect!
		dvg_zhourao.5 # One Kongsi
		dvg_oceania.2 #Australia Gamerule, if in the future there is an ability to add state traits or even just a better way someone finds, please change this.
		dvg_oceania.50 #Convention of Zhourao
		dvg_cossacks.2 # End of Cossack Neutrality
	}
	effect = {
	}
	# Election Events
	random_events = {
		50 = 0
		1 = election_liberal_events.1
		1 = election_liberal_events.2
		1 = election_liberal_events.3
		1 = election_liberal_events.4
		1 = election_conservative_events.1
		1 = election_conservative_events.2
		1 = election_conservative_events.3
		1 = election_conservative_events.4
		1 = election_moderate_events.1
		1 = election_moderate_events.2
		1 = election_contextual_events.1
		1 = election_contextual_events.2
		1 = election_contextual_events.3
		1 = election_contextual_events.4
		1 = election_contextual_events.5
		1 = election_contextual_events.6
		1 = election_contextual_events.7
		1 = election_contextual_events.8
		1 = election_neutral.1
		1 = election_neutral.2
		1 = election_neutral.3
		1 = election_neutral.4
		1 = election_neutral.5
		1 = election_neutral.6
		1 = election_neutral.7
		1 = election_neutral.8
		1 = election_other_parties_events.1
		1 = election_other_parties_events.2
		1 = election_other_parties_events.3
		1 = election_other_parties_events.4
		1 = election_other_parties_events.5
		1 = ig_leaders.3
	}
}

on_yearly_pulse_country = { #Krakatoa special pulse
	random_events = {
		47 = 0
		1 = krakatoa.1
	}
	random_events = {
		11 = 0
		1 = tunguska.1
	}
}

on_yearly_pulse_country = {
	effect = {
		# IG leader death
		random_list = {
			1 = {
				trigger_event = { id = character_events.100 }
			}
			1 = { }
		}
	}

	random_events = {
		150 = 0

		20 = government_conflicts.1
		20 = government_conflicts.2
		20 = government_conflicts.3
		20 = government_conflicts.4
		20 = government_conflicts.5
		20 = government_conflicts.6
		20 = government_conflicts.7
		20 = government_conflicts.8
		20 = government_conflicts.9
		20 = government_conflicts.10
		20 = government_conflicts.11
		#
		10 = goldrush.3
		10 = goldrush.4
		#
		20 = ig_leaders.20
		20 = ig_leaders.4
		20 = ig_leaders.5
		20 = ig_leaders.6

		#Character Events
		20 = character_events.2
		20 = character_events.3
		20 = character_events.4
		20 = character_events.5
		100 = character_events.6
		
		# Border Situations
		20 = neighbor_events.1
		20 = neighbor_events.2
		20 = neighbor_events.3
		20 = neighbor_events.4
		20 = neighbor_events.5
		20 = neighbor_events.6
		20 = neighbor_events.7

		# Commander Events
		20 = commander_events.2
		20 = commander_events.4
		20 = commander_events.5
		5 = commander_events.6

		# Law Events
		50 = law_events.5
		50 = law_events.6

		# Cultural Homeland Events
        10 = cultural_homeland_events.1
        10 = cultural_homeland_events.10
        10 = cultural_homeland_events.20
        10 = cultural_homeland_events.30
        10 = cultural_homeland_events.40
        10 = cultural_homeland_events.50

		# IGs and Revolutions
		20 = ig_revolutions.1
		20 = ig_revolutions.2
		20 = ig_revolutions.3
		20 = ig_revolutions.4
		20 = ig_revolutions.5
		20 = ig_revolutions.6
		20 = ig_revolutions.7
		20 = ig_revolutions.8
		20 = ig_revolutions.9
		
		#IG Suppression
		20 = ig_suppression_events.1

		# Technology
		20 = technology_events.1
		20 = technology_events.10
		20 = technology_events.20
		20 = technology_events.30
		20 = technology_events.40
		20 = technology_events.50
		
		# Industrial Accidents
		10 = industrial_accident_events.1
		10 = industrial_accident_events.2
		10 = industrial_accident_events.3
		10 = industrial_accident_events.4
		20 = industrial_accident_events.5
		20 = industrial_accident_events.6

		# Crime (Why do police not just comment out crime events?)
		10 = crime_events.1
		10 = crime_events.2
		10 = crime_events.10

		# Obligations
		10 = obligation_events.1
		10 = obligation_events.3
		10 = obligation_events.5
		
		# Prostitution and police
		20 = prostitution.1
		20 = prostitution.2
		20 = prostitution.3
		20 = prostitution.4
		20 = cable_street.1

		#Natural Disasters
		3 = natural_disaster_events.1
		3 = natural_disaster_events.2
		1 = natural_disaster_events.3
		1 = natural_disaster_events.4
		3 = natural_disaster_events.5
		3 = natural_disaster_events.6
		3 = natural_disaster_events.7
		1 = natural_disaster_events.8
		
		# # Taiping Heavenly Kingdom
		# 20 = heavenly.1

		# # Warlords
		# 20 = warlord_china_events.110
		# 20 = warlord_china_events.301
		
		# Assassination
		10 = assassination_events.1

		# Oil Rush Scandal
		20 = oil_rush.5
		
		#Decree
		20 = decree_events.1
		20 = decree_events.2
		20 = decree_events.3
		20 = decree_events.4
		20 = decree_events.5
		20 = decree_events.6
		20 = decree_events.100
		20 = decree_events.101
		20 = decree_events.102
		20 = decree_events.103
		20 = decree_events.104
		20 = decree_events.105
		20 = decree_events.106
		20 = decree_events.107
		20 = decree_events.108
		20 = decree_events.109
		
		50 = strike.5
		50 = strike.6
		50 = strike.7

		10 = opium_wars.8

		# 10 = south_america.3
		
		20 = communism.9
		20 = communism.7

		100 = nihilism.1
		
		#psychology
		20 = psychology_events.1
		20 = psychology_events.2
		20 = psychology_events.3
		20 = psychology_events.4
		20 = psychology_events.5
		20 = psychology_events.6
		
		#nationalism
		20 = fascism_events.8

		20 = dreadnought_hoax.1

		#10 = patagonia.2#
		10 = amazon.1
		10 = amazon.2

		10 = amazon.4 # The Most Dangerous Game

		20 = autocracy.2
		20 = autocracy.3

		# rivalry events
		10 = diplomatic_friction.1
		10 = diplomatic_friction.2
		10 = diplomatic_friction.20
		
		# Titanic
		10 = titanic.1

		# trains
		5 = trains.1

		30 = cholera.1

		# Slave revolts
		5 = slave_revolt.1
		5 = slave_revolt.2
		5 = slave_revolt.3

		# Discrimination Events
		20 = discrimination_events.1
		20 = discrimination_events.2
		20 = discrimination_events.3
		20 = discrimination_events.4

		# Trade routes
		20 = trade_route_events.1
		20 = trade_route_events.2
		20 = trade_route_events.3
		20 = trade_route_events.4
		20 = trade_route_events.5
		
		#PMs
		20 = pm_events.1
		20 = pm_events.2
		20 = pm_events.4
		20 = pm_events.5
		
		# Vampire Panic
		1 = vampire_panic.1
	}

	# Springtime of the Peoples
	random_events = {
		5 = 0
		1 = peoples_springtime.6
	}
	
	random_events = {
	}

	random_events = {
		4 = 0
		1 = wedding.1 # on average, monarchs should marry within 5 years of coming of age
	}

	#Slavery Abolition
	random_events = {
		4 = 0
		1 = slavery_law_events.7
	}
}
on_half_yearly_pulse_country = {
	# random_events = {
		# 100 = 0
		
		# # The Attempt on Lincoln's Life
		# 40 = acw_followup_events.1
		# 10 = acw_followup_events.2
		# 50 = acw_followup_events.3

		# # Oscar Wilde event for Europe
		# 5 = oscar_wilde_events.1
	# }
	# Secession
	random_events = {
		20 = secession_events.1
		20 = secession_events.2
		20 = secession_events.3
		20 = secession_events.4
		20 = secession_events.5
		20 = secession_events.6
		20 = secession_events.7
		20 = secession_events.8
		20 = secession_events.9
	}
}
on_five_year_pulse_country = {
	events = {
		generals.1
	}
}


on_decade_pulse_country = {
	random_events = {
		99 = 0
		1 = plague.1
	}
}

# Root = Character
on_monthly_pulse_character = {}
on_yearly_pulse_character = {
	random_events = {
		20 = character_events.1
	}


}
on_half_yearly_pulse_character = {}
on_five_year_pulse_character = {}
on_decade_pulse_character = {
	
}

# Root = State
on_monthly_pulse_state = {
	random_events = {
		10 = goldrush.5
	}

}
on_half_yearly_pulse_state = {}
on_yearly_pulse_state = {
	random_events = {
		80 = 0
		10 = oil_rush.3
		10 = oil_rush.4
	}
	on_actions = {
	}
}
on_five_year_pulse_state = {}
on_decade_pulse_state = {}

# Root = attacker or defender country
# scope:battle = battle
# scope:attacker = attacking commander
# scope:defender = defending commander
# scope:state = location state
on_battle_started = {
	effect = {
	}
}

# Root = attacker or defender country
# scope:battle = battle
# scope:attacker = attacking commander
# scope:defender = defending commander
# scope:state = location state
on_battle_ended = {}

# Root = attacker or defender country
# scope:battle = battle
# scope:attacker = attacking commander
# scope:defender = defending commander
# scope:state = location state
on_battle_won = {
	# events = {
		# texan_war_of_independence.3
	# }
}

# Root = attacker or defender country
# scope:battle = battle
# scope:attacker = attacking commander
# scope:defender = defending commander
# scope:state = location state
on_battle_lost = {}

# Root = Building
on_building_built = {
}

# Root = Building
on_start_expanding_building = {
}

# Root = Building
on_building_expanded = {
}

# Does not appear
on_deactivate_link = {
}

# Root = From Market
# scope:market = Market merging into
# scope:trade_center = Trade Center state of root
on_merge_markets = {
}

# Root = State having the link retargeted
on_retarget_link = {
}

# Root = The newly created market
on_create_market = {
}

# Root = The applicable country
# scope:technology = The technology type they started to research
on_research_technology_started = {
	effect = {
		if = {
			limit = { 
				has_journal_entry = je_tutorial_research_technology
			}
			je:je_tutorial_research_technology = {
				set_target_technology = scope:technology
			}
			set_variable = tut_began_new_research
		}
	}
}

# Root = The applicable country
# scope:technology = The technology type they just acquired
on_acquired_technology = {
	effect = {
		if = {
			limit = {
				has_game_started = yes
			}
			post_notification = acquired_technology_notification
		}
		if = {
			limit = {
				is_player = yes
				has_technology_researched = pumpjacks
				NOT = { has_variable = first_oil_discovered }
			}
			set_variable = first_oil_discovered
			if = {
				limit = {
					any_scope_state = {
						has_potential_resource = bg_oil_extraction
					}
				}
				random_scope_state = {
					limit = {
						has_potential_resource = bg_oil_extraction
					}
					force_resource_discovery = bg_oil_extraction
				}
			}
			else_if = {
				limit = {
					any_country = {
						has_overlapping_interests = ROOT
						any_scope_state = {
							has_potential_resource = bg_oil_extraction
						}
					}
				}
				random_country = {
					limit = {
						has_overlapping_interests = ROOT
						any_scope_state = {
							has_potential_resource = bg_oil_extraction
						}
					}
					random_scope_state = {
						limit = {
							has_potential_resource = bg_oil_extraction
						}
						force_resource_discovery = bg_oil_extraction
					}
				}
			}
			else = {
				random_state = {
					limit = {
						has_potential_resource = bg_oil_extraction
					}
					force_resource_discovery = bg_oil_extraction
				}
			}
		}
	}

	events = {
		historical_events.1
		marx_events.1
	}
}

# Root = The applicable country
# scope:technology = The technology type that has started to spread to them
on_spreading_technology = {
	effect = {
		post_notification = spreading_technology_notification
	}
}

# Fires for all countries with an interest marker in the play's region
# Root = Country who owns the interest marker
# scope:diplomatic_play = The diplomatic play that has been started
on_diplomatic_play_started = {
	events = {
	}
}

# Root = Character
on_character_creation = {
}

# Root = Character
on_character_death = {
	effect = {
		if = {
			limit = {
				is_ruler = yes
				exists = c:HAW
				owner = c:HAW
				owner = {
					has_law = law_type:law_monarchy
					NOT = { has_variable = death_of_kamehameha }
					NOT = { has_global_variable = gp_hawaii_interest }
				}
			}
			owner = {
				trigger_event = hawaii_events.1
			}
		}
		
		if = {
			limit = {
				has_variable = expedition_leader_var
			}
			owner = {
				trigger_event = expedition_events.110
			}
		}
	}
}

# Root = Character
on_new_ruler = {
	#
}

# Root = Country
on_country_default = {
	effect = {
		add_modifier = country_default	
	}
}

# Root = Country
on_country_no_longer_default = {
	effect = {
		remove_modifier = country_default	
	}
}

# Root = Diplomatic Action
on_diplomatic_action = {
	effect = {
		post_notification = diplomatic_action_notification
	}
}

# Root = Diplomatic Action
on_diplomatic_proposal = {
	effect = {
		post_proposal = proposal_diplomatic_action
	}
}

# Root = Diplomatic Action
on_diplomatic_proposal_accepted = {
	effect = {
		post_notification = diplomatic_proposal_accepted
	}
}

# Root = Diplomatic Action
on_diplomatic_proposal_owe_obligation = {
	effect = {
		post_proposal = proposal_diplomatic_action_owe_obligation
	}
}

# Root = Diplomatic Action
on_diplomatic_proposal_call_in_obligation = {
	effect = {
		post_proposal = proposal_diplomatic_action_call_in_obligation
	}
}

# Root = Diplomatic Action
on_diplomatic_proposal_declined = {
	effect = {
		post_notification = diplomatic_proposal_declined
	}
}

# Root = Diplomatic Action
on_diplomatic_action_break = {
	effect = {
		post_notification = diplomatic_action_break_notification
	}
}

# Root = Diplomatic Action
on_diplomatic_proposal_break = {
	effect = {
		post_proposal = proposal_break_pact
	}
}

# Root = Diplomatic Action
on_diplomatic_proposal_break_accepted = {
	effect = {
		post_notification = diplomatic_proposal_break_accepted
	}
}

# Root = Diplomatic Action
on_diplomatic_proposal_break_owe_obligation = {
	effect = {
		post_proposal = proposal_break_pact_owe_obligation
	}
}

# Root = Diplomatic Action
on_diplomatic_proposal_break_call_in_obligation = {
	effect = {
		post_proposal = proposal_break_pact_call_in_obligation
	}
}

# Root = Diplomatic Action
on_diplomatic_proposal_break_declined = {
	effect = {
		post_notification = diplomatic_proposal_break_declined
	}
}

# Root = Diplomatic Action
on_diplomatic_action_third_party = {
	effect = {
		post_notification = diplomatic_proposal_third_party_notification
	}
}

# Root = Diplomatic Action
on_diplomatic_action_third_party_accepted = {
	effect = {
		post_notification = diplomatic_proposal_third_party_accepted
	}
}

# Root = Diplomatic Action
on_diplomatic_action_third_party_declined = {
	effect = {
		post_notification = diplomatic_proposal_third_party_declined
	}
}

# Root = Diplomatic Action
on_diplomatic_action_third_party_break = {
	effect = {
		post_notification = diplomatic_proposal_third_party_break_notification
	}
}

# Root = Diplomatic Action
on_diplomatic_action_third_party_break_accepted = {
	effect = {
		post_notification = diplomatic_proposal_third_party_break_accepted
	}
}

# Root = Diplomatic Action
on_diplomatic_action_third_party_break_declined = {
	effect = {
		post_notification = diplomatic_proposal_third_party_break_declined
	}
}

# Root = Diplomatic Action
on_diplomats_expelled = {
	effect = {
		if = {
			limit = {
				scope:initiator = {
					has_variable = we_are_not_amused_ach_possible
				}
				scope:target = c:FRA
				scope:initiator = {
					"relations(scope:target)" >= relations_threshold:cordial
				}
			}
			set_variable = achievement_we_are_not_amused
		}
	}
}

# Root = Diplomatic Pact
on_diplomatic_pact_auto_break = {
	effect = {
		post_notification = diplomatic_pact_auto_break_notification
	}
}

# Root = Diplomatic Pact
on_diplomatic_pact_third_party_auto_break = {
	effect = {
		post_notification = diplomatic_pact_third_party_auto_break_notification
	}
}

# Root = Releasing Country
# scope:target = Released Country
on_country_released_as_independent = {
	effect = {
		if = {
			limit = {
				scope:target = {
					country_has_primary_culture = cu:ashkenazi
				}
				NOT = {
					s:STATE_PALESTINE = {
						is_homeland = cu:ashkenazi
					}
				}
			}
			s:STATE_PALESTINE = {
				add_homeland = sephardic
				add_homeland = ashkenazi
			}
		}
		scope:target = {
			if = {
				limit = {
					country_has_state_religion = rel:theravada
				}
				ig:ig_devout = {
					set_interest_group_name = ig_theravada_monks
					remove_ideology = ideology_moralist
					add_ideology = ideology_buddhist_moralist
				}
			}
			if = {
				limit = {
					country_has_state_religion = rel:orthodox
					OR = {
						NOT = { exists = c:RUS }
						NOT = { c:RUS = scope:target }
					}
				}
				ig:ig_devout = {
					set_interest_group_name = ig_orthodox_church
					remove_ideology = ideology_patriarchal
					add_ideology = ideology_orthodox_patriarch
				}
			}
			if = {
				limit = {
					exists = c:RUS
					c:RUS = scope:target
				}
				ig:ig_devout = {
					set_interest_group_name = ig_orthodox_church
					remove_ideology = ideology_patriarchal
					add_ideology = ideology_russian_patriarch
				}
			}
			if = {
				limit = {
					country_has_state_religion = rel:hindu
				}
				ig:ig_devout = {
					set_interest_group_name = ig_hindu_priesthood
					remove_ideology = ideology_hindu_moralist
					add_ideology = ideology_hindu_moralist
				}
			}
			if = {
				limit = {
					country_has_state_religion = rel:mahayana
				}
				ig:ig_devout = {
					set_interest_group_name = ig_vajrayana_monks
					remove_ideology = ideology_moralist
					add_ideology = ideology_buddhist_moralist
				}
			}
			if = {
				limit = {
					country_has_state_religion = rel:sikh
				}
				ig:ig_devout = {
					set_interest_group_name = ig_sikh_priesthood
					remove_ideology = ideology_moralist
					add_ideology = ideology_sikh_moralist
				}
			}
			if = {
				limit = {
					country_has_state_religion = rel:oriental_orthodox
				}
				ig:ig_devout = {
					set_interest_group_name = ig_oriental_orthodox_church
					remove_ideology = ideology_patriarchal
					add_ideology = ideology_oriental_orthodox_patriarch
				}
			}
		}
	}
}

# Root = Releasing Country
# scope:target = Released Country
on_country_released_as_own_subject = {
	effect = {
		if = {
			limit = {
				scope:target = {
					country_has_primary_culture = cu:ashkenazi
				}
				NOT = {
					s:STATE_PALESTINE = {
						is_homeland = cu:ashkenazi
					}
				}
			}
			s:STATE_PALESTINE = {
				add_homeland = sephardic
				add_homeland = ashkenazi
			}
		}
		scope:target = {
			if = {
				limit = {
					country_has_state_religion = rel:theravada
				}
				ig:ig_devout = {
					set_interest_group_name = ig_theravada_monks
					remove_ideology = ideology_moralist
					add_ideology = ideology_buddhist_moralist
				}
			}
			if = {
				limit = {
					exists = c:RUS
					c:RUS = scope:target
				}
				ig:ig_devout = {
					set_interest_group_name = ig_orthodox_church
					remove_ideology = ideology_patriarchal
					add_ideology = ideology_russian_patriarch
				}
			}
			if = {
				limit = {
					country_has_state_religion = rel:orthodox
					OR = {
						NOT = { exists = c:RUS }
						NOT = { c:RUS = scope:target }
					}
				}
				ig:ig_devout = {
					set_interest_group_name = ig_orthodox_church
					remove_ideology = ideology_patriarchal
					add_ideology = ideology_orthodox_patriarch
				}
			}
			if = {
				limit = {
					country_has_state_religion = rel:hindu
				}
				ig:ig_devout = {
					set_interest_group_name = ig_hindu_priesthood
					remove_ideology = ideology_hindu_moralist
					add_ideology = ideology_hindu_moralist
				}
			}
			if = {
				limit = {
					country_has_state_religion = rel:vajrayana
				}
				ig:ig_devout = {
					set_interest_group_name = ig_vajrayana_monks
					remove_ideology = ideology_moralist
					add_ideology = ideology_buddhist_moralist
				}
			}
			if = {
				limit = {
					country_has_state_religion = rel:sikh
				}
				ig:ig_devout = {
					set_interest_group_name = ig_sikh_priesthood
					remove_ideology = ideology_moralist
					add_ideology = ideology_sikh_moralist
				}
			}
			if = {
				limit = {
					country_has_state_religion = rel:oriental_orthodox
				}
				ig:ig_devout = {
					set_interest_group_name = ig_oriental_orthodox_church
					remove_ideology = ideology_patriarchal
					add_ideology = ideology_oriental_orthodox_patriarch
				}
			}
		}
	}
}

# Root = Releasing Country
# scope:target = Released Country
on_country_released_as_overlord_subject = {
	effect = {
		if = {
			limit = {
				scope:target = {
					country_has_primary_culture = cu:ashkenazi
				}
				NOT = {
					s:STATE_PALESTINE = {
						is_homeland = cu:ashkenazi
					}
				}
			}
			s:STATE_PALESTINE = {
				add_homeland = sephardic
				add_homeland = ashkenazi
			}
		}
		scope:target = {
			if = {
				limit = {
					country_has_state_religion = rel:theravada
				}
				ig:ig_devout = {
					set_interest_group_name = ig_theravada_monks
					remove_ideology = ideology_moralist
					add_ideology = ideology_buddhist_moralist
				}
			}
			if = {
				limit = {
					country_has_state_religion = rel:orthodox
					OR = {
						NOT = { exists = c:RUS }
						NOT = { c:RUS = scope:target }
					}
				}
				ig:ig_devout = {
					set_interest_group_name = ig_orthodox_church
					remove_ideology = ideology_patriarchal
					add_ideology = ideology_orthodox_patriarch
				}
			}
			if = {
				limit = {
					exists = c:RUS
					c:RUS = scope:target
				}
				ig:ig_devout = {
					set_interest_group_name = ig_orthodox_church
					remove_ideology = ideology_patriarchal
					add_ideology = ideology_russian_patriarch
				}
			}
			if = {
				limit = {
					country_has_state_religion = rel:hindu
				}
				ig:ig_devout = {
					set_interest_group_name = ig_hindu_priesthood
					remove_ideology = ideology_hindu_moralist
					add_ideology = ideology_hindu_moralist
				}
			}
			if = {
				limit = {
					country_has_state_religion = rel:vajrayana
				}
				ig:ig_devout = {
					set_interest_group_name = ig_vajrayana_monks
					remove_ideology = ideology_moralist
					add_ideology = ideology_buddhist_moralist
				}
			}
			if = {
				limit = {
					country_has_state_religion = rel:sikh
				}
				ig:ig_devout = {
					set_interest_group_name = ig_sikh_priesthood
					remove_ideology = ideology_moralist
					add_ideology = ideology_sikh_moralist
				}
			}
			if = {
				limit = {
					country_has_state_religion = rel:oriental_orthodox
				}
				ig:ig_devout = {
					set_interest_group_name = ig_oriental_orthodox_church
					remove_ideology = ideology_patriarchal
					add_ideology = ideology_oriental_orthodox_patriarch
				}
			}
		}
	}
}

# Root = State
on_migration_target_created = {
	effect = {
		post_notification = migration_target_created
	}
}

# Root = State
on_migration_target_created_other = {
	effect = {
		post_notification = migration_target_created_other
	}
}

# Root = State
on_resource_discovered = {
	events = {
		goldrush.1
		oil_rush.1
		rubber_events.1
	}
}

# Root = State
on_resource_depleted = {
	effect = {
		owner = {
			post_notification = resource_depleted
		}
	}
	events = {
		goldrush.2
	}
}

# Root = Country
on_peace_agreement_signed_war_leader = {
	effect = {
		post_notification = peace_agreement_signed_war_leader
	}
}

# Root = Country
on_peace_agreement_signed_war_participant = {
	effect = {
		post_notification = peace_agreement_signed_war_participant
	}
}

# Root = Country
on_peace_agreement_signed_non_participant = {
	effect = {
		post_notification = peace_agreement_signed_non_participant
	}
}

# Root = Country
on_capitulation = {
	effect = {
	}
}

# Root = Country
on_self_capitulated_notification = {
	effect = {
		post_notification = self_capitulated
		set_variable = {
			name = recent_capitulation
			months = short_modifier_time
		}
	}
}

# Root = Country
on_enemy_capitulated_notification = {
	effect = {
		post_notification = enemy_capitulated
	}
}

# Root = Country
on_ally_capitulated_notification = {
	effect = {
		post_notification = ally_capitulated
	}
}

# Root = Diplomatic Play
on_diplo_play_start = {
	effect = {
		post_notification = diplo_play_start_notification
	}
}

# Root = Diplomatic Play
on_diplo_play_start_third_party = {
	effect = {
		post_notification = diplo_play_start_third_party_notification
	}
}

# Root = Diplomatic Play
on_diplo_play_back_down = {
	effect = {
		post_notification = diplo_play_back_down_notification
		if = {
			limit = {
				scope:notification_target = {
					is_player = yes
				}
				scope:actor = {
					is_player = no
				}
			}
			set_global_variable = achievement_mightier_than_the_sword
		}
	}
}

# Root = Diplomatic Play
on_diplo_play_back_down_involved = {
	effect = {
		post_notification = diplo_play_back_down_involved_notification
	}
}

# Root = Diplomatic Play
on_diplo_play_join_side = {
	effect = {
		post_notification = diplo_play_join_side_notification
	}
}

# Root = Diplomatic Play
on_diplo_play_abandon_side = {
	effect = {
		post_notification = diplo_play_abandon_side_notification
	}
}

# Root = Diplomatic Play
on_diplo_play_war_start = {
	effect = {
		post_notification = diplo_play_war_start_notification
		post_notification = diplo_play_war_start_third_party_notification
	}
}

# Root = Diplomatic Play
on_diplo_play_subject_released = {
	effect = {
		post_notification = diplo_play_subject_released_notification
	}
}

# Root = Diplomatic Play
on_diplo_play_subject_released_overlord = {
	effect = {
		post_notification = diplo_play_subject_released_overlord_notification
	}
}

# Root = Diplomatic Play
# country = Country switched to
# previous = Country switched from
on_diplo_play_switch_sides = {
	effect = {
		set_global_variable = achievement_revo_needed
	}
}

# Root = Diplomatic Play
on_diplo_play_declare_neutrality = {
	effect = {
		post_notification = diplo_play_declare_neutrality_notification
	}
}


# Root = Diplomatic Play
on_sway_offer = {
	effect = {
		post_proposal = proposal_sway_offer
	}
}

# Root = Diplomatic Play
on_sway_offer_owe_obligation = {
	effect = {
		post_proposal = proposal_sway_offer_owe_obligation
	}
}


# Root = Diplomatic Play
on_sway_offer_accepted = {
	effect = {
		post_notification = sway_offer_accepted
	}
}

# Root = Diplomatic Play
on_country_swayed = {
	effect = {
		post_notification = country_swayed
	}
}

# Root = Diplomatic Play
on_sway_offer_rejected = {
	effect = {
		post_notification = sway_offer_rejected
	}
}

# Root = Building
on_production_method_changed = {
	effect = {
		owner = {
			if = {
				limit = { 
					has_journal_entry = je_tutorial_change_production_method
					je:je_tutorial_change_production_method.target = root
				}
				set_variable = has_changed_production_method
			}
		}	
	}
}

# Root = owner Country of the Law
# executed when enactment of any law begins
on_law_enactment_started = {
	effect = {
		if = {
			limit = {
				has_law = law_type:law_monarchy
				OR = {
					is_enacting_law = law_type:law_presidential_republic
					is_enacting_law = law_type:law_parliamentary_republic
					is_enacting_law = law_type:law_council_republic
				}
			}
			set_variable = {
				name = abolishing_monarchy_var
				value = 0
			}
			add_journal_entry = { type =  je_abolish_monarchy }
		}
	}
}

# Root = owner Country of the Law
# executed when the end of a checkpoint is reached and the result is success
# (currently, this means the law will get enacted so it will be followed by
# on_law_enactment_ended and on_law_enacted).
#
# NOTE: at the point in time when this on-action is triggered, the law
# is still considered being enacted, therefore the `currently_enacting_law` link
# will work as expected, even though the enactment is about to end
on_law_checkpoint_success = {
	effect = {

	}
}

# Root = owner Country of the Law
# executed when the end of a checkpoint is reached and the result is advance
on_law_checkpoint_advance = {
	random_events = {
		10 = laws.1
		10 = children_rights_events.1 
		10 = free_speech_laws.1
		10 = free_speech_laws.2
		10 = labor_rights.1
		10 = labor_rights.4
		10 = children_rights_events.4
		10 = welfare_laws.1
		10 = welfare_laws.4
		10 = welfare_laws.8
		10 = migration_laws.1
		10 = migration_laws.4
		10 = bureaucracy.2
		10 = colonization.1
		10 = colonization.3
		10 = rights_of_women_laws.1
		10 = rights_of_women_laws.2
		10 = internal_security_events.2
		10 = slavery_law_events.1
		10 = slavery_law_events.4
		10 = laws_police.1
		10 = anarchy.3
		10 = tax.2
		10 = tax.5
		10 = theocracy.1
		10 = citizenship_laws.1
		10 = citizenship_laws.4
		100 = 1848.1
		100 = 1848.3
		10 = education_laws.1
		10 = education_laws.4
		10 = distribution_of_power_laws.1
		10 = council_republic_law_events.1
		10 = distribution_of_power_laws.4
		10 = monarchy_law_events.1
		10 = monarchy_law_events.2
		10 = economy_laws.1
		10 = economy_laws.4
		10 = meiji.4
		10 = meiji.5
		10 = meiji.6
		10 = conscription_laws.1
		10 = republic_laws.1
		10 = internal_security_events.4
		10 = healthcare_laws.1
		10 = healthcare_laws.4
		10 = anti_state_religion.1
		10 = distribution_of_power_laws.7
		10 = distribution_of_power_laws.10
		10 = rights_of_women_laws.5
		2 = generic_laws.1
		2 = generic_laws.4
		2 = generic_laws.7
		2 = generic_laws.10
		2 = ig_petitions.4 #Devout want State Religion
		2 = ig_petitions.7 #Intelligentsia want free speech
		2 = ig_petitions.19 #Armed forces want conscription
		2 = ig_petitions.22 #Petite-Bourgeoisie want Restricted Citizenship
		1 = law_notification.1
	}
	effect = {

	}
}

# Root = owner Country of the Law
# executed when the end of a checkpoint is reached and the result is debate
on_law_checkpoint_debate = {
	random_events = {
		10 = children_rights_events.2
		10 = free_speech_laws.5
		10 = labor_rights.2
		10 = labor_rights.5
		10 = children_rights_events.6
		10 = welfare_laws.2
		10 = welfare_laws.5
		10 = welfare_laws.9
		10 = migration_laws.2
		10 = migration_laws.5
		10 = bureaucracy.3
		10 = colonization.1
		10 = free_speech_laws.5
		10 = free_speech_laws.6
		10 = internal_security_events.3
		10 = slavery_law_events.2
		10 = slavery_law_events.5
		10 = laws_police.2
		10 = anarchy.2
		10 = tax.3
		10 = tax.6
		10 = theocracy.2
		10 = citizenship_laws.2
		10 = citizenship_laws.5
		10 = education_laws.2
		10 = education_laws.5
		100 = 1848.1
		100 = 1848.3
		10 = distribution_of_power_laws.2
		10 = council_republic_law_events.2
		10 = distribution_of_power_laws.5
		10 = monarchy_law_events.3
		10 = economy_laws.2
		10 = economy_laws.5
		10 = isolation.2
		10 = conscription_laws.2
		10 = republic_laws.2
		10 = internal_security_events.5
		10 = healthcare_laws.2
		10 = healthcare_laws.5
		10 = anti_state_religion.2
		10 = colonization.4
		10 = distribution_of_power_laws.8
		10 = distribution_of_power_laws.11
		10 = rights_of_women_laws.4
		10 = law_events.1
		2 = generic_laws.3
		2 = generic_laws.6
		2 = generic_laws.9
		2 = generic_laws.12
		10 = ig_petitions.1 #Landowners want to reverse Suffrage
		10 = ig_petitions.10 #Rural folk want no conscription
		10 = ig_petitions.13 #Trade Unions want compulsory primary school
		20 = ig_petitions.16 #Industrialists want no graduated taxes
		1 = law_notification.2
	}
	effect = {
	}
	events = {
		tanzimat_events.1
		tanzimat_events.2
		tanzimat_events.4
	}
}

# Root = owner Country of the Law
# executed when the end of a checkpoint is reached and the result is stall
#
# NOTE: at the point in time when this on-action is triggered, the law
# is still considered being enacted, therefore the `currently_enacting_law` link
# will work as expected, even if the resulting event is particularly bad and
# will proceed to stop the enactment
on_law_checkpoint_stall = {
	random_events = {
		10 = children_rights_events.3
		10 = free_speech_laws.3
		10 = free_speech_laws.4
		10 = labor_rights.3
		10 = labor_rights.6
		10 = children_rights_events.5
		10 = welfare_laws.3
		10 = welfare_laws.6
		10 = welfare_laws.10
		10 = migration_laws.3
		10 = migration_laws.6
		10 = bureaucracy.1
		10 = colonization.1
		10 = colonization.2
		10 = rights_of_women_laws.3
		10 = internal_security_events.1
		10 = slavery_law_events.3
		10 = slavery_law_events.6
		10 = laws_police.3
		10 = anarchy.1
		10 = tax.1
		10 = tax.4
		10 = theocracy.3
		10 = citizenship_laws.3
		10 = citizenship_laws.6
		10 = education_laws.3
		10 = education_laws.6
		100 = 1848.1
		100 = 1848.3
		10 = distribution_of_power_laws.3
		10 = council_republic_law_events.3
		10 = distribution_of_power_laws.6
		10 = monarchy_law_events.4
		10 = economy_laws.3
		10 = economy_laws.6
		10 = isolation.1
		10 = conscription_laws.3
		10 = republic_laws.3
		10 = internal_security_events.6
		10 = healthcare_laws.3
		10 = healthcare_laws.6
		10 = anti_state_religion.3
		10 = distribution_of_power_laws.9
		10 = distribution_of_power_laws.12
		10 = rights_of_women_laws.6
		2 = generic_laws.2
		2 = generic_laws.5
		2 = generic_laws.8
		2 = generic_laws.11
		1 = law_notification.3
	}
	effect = {
	}
}

# Root = owner Country of the Law
# executed when enactment stops for any reason. Could be because the law has
# been enacted, or because the enactment has been stopped by the player.
#
# NOTE: at the point in time when this on-action is triggered, the law
# is still considered being enacted, therefore the `currently_enacting_law` link
# will work as expected, even though the enactment is _just_ about to end
on_law_enactment_ended = {
	effect = {
	}
}

# Root owner Country of the Law
# executed when the law is activated for any reason. It's usually because it
# has been enacted, but script can activate laws directly without going through
# the enactment process. Normally, it's immediately preceded by
# on_law_enactment_ended, but if a law is directly set by script, thus
# bypassing the enactment process, this will execute while
# on_law_enactment_ended will not
#
# NOTE: unlike the other on_law_<something> on-actions, at the point in time
# when this is triggered the law that was enacted is no longer considered being
# enacted. Therefore using the `currently_enacting_law` link will return the
# null law
on_law_activated = {
	effect = {

	}

}

# Root = Institution
on_investment_increased = {
	effect = {
		post_notification = institution_investment_increased
	}
}

# Root = Institution
on_investment_decreased = {
	effect = {
		post_notification = institution_investment_decreased
	}
}

# Root = Country
# scope:target = Uprising country
on_revolution_start = {
	effect = {
		if = {
            limit = {
                has_journal_entry = je_meiji_restoration
                scope:target = {
                    ig:ig_landowners = {
                        is_in_government = yes
                    }
                }
            }
            set_variable = anti_shogunate_civil_war
        }
	}
}

# Root = Country
# scope:target = Uprising country
on_revolution_end = {
	effect = {
		if = {
			limit = {
				exists = c:BOH
				ROOT = c:BOH
				country_has_primary_culture = cu:north_german
			}
			scope:target = {
				add_primary_culture = cu:north_german
			}
		}
		if = {
			limit = {
				exists = c:GER
				ROOT = c:GER
				country_has_primary_culture = cu:czech
			}
			scope:target = {
				add_primary_culture = cu:czech
			}
		}
	}
}

# Root = Country
# scope:target = Uprising country
on_secession_start = {
	effect = {
	}
}

# Root = Country
# scope:target = Uprising country
on_secession_end = {
}

# Root = Country
# This action is triggered after `on_revolution_end`
on_civil_war_won = {
	effect = {
		if = {
			limit = {
				has_global_variable = achievement_revo_needed
			}
			set_global_variable = achievement_revolutionary
		}
		if = {
			limit = {
				has_journal_entry = je_meiji_restoration
				has_variable = anti_shogunate_civil_war
				has_variable = shogunate_var
			}
			change_variable = {
				name = shogunate_var
				add = 120
			}
			remove_variable = anti_shogunate_civil_war
		}
	}
}

# Root = Country
on_wargoal_enforced = {
	effect = {
		# set_variable = { #Only used in Brazil starting war event
            # name = recently_won_war
            # days = 600
            # value = yes
        # }
	}
	
}

# Root = Interest Group
on_ig_resigned_government = {
	effect = {
		post_notification = ig_resigned_government
	}
}

# Root = Culture
on_new_culture_obsession = {
	effect = {
		post_notification = new_culture_obsession
	}
}

# Root = Country
on_rank_changed = {
	effect = {
		post_notification = rank_changed_notification
	}
}

# Root = Character
on_heir_born = {
	effect = {
		if = {
			limit = {
				exists = c:NZH
				owner = c:NZH
				NOT = { has_variable = gay_green_prince }
			}
			# We kill of auto generated heirs until the propper heir is born
			kill_character = yes
		}
		else = {
			post_notification = heir_born_notification
		}
	}
}

# Root = Home Country
# scope:target = Secession country
on_secession_country_helped_by_home_country = {
	effect = {
		annex = scope:target
	}
}

# Root = Home Countr
# scope:target = Secession country
on_secession_country_not_helped_by_home_country = {
	effect = {
		trigger_event = { id = civil_war_events.1 days = 0 }
	}
}

# Root = Diplomatic Play
# scope:actor = War Goal Owner
on_wargoal_added = {
	effect = {
		post_notification = wargoal_added
	}
}

# Root = Diplomatic Play
# scope:actor = War Goal Owner
on_wargoal_removed = {
	effect = {
		post_notification = wargoal_removed
	}
}

# Root = Diplomatic Play
# scope:actor = Initiator country
# scope:target = Target country
on_war_end = {
	#effect = {
	#	if = {
	#		limit = {
	#			NOT = { has_global_variable = selon_treaty_void }
	#			scope:actor = {
	#				country_is_in_europe = yes
	#			}
	#			scope:target = {
	#				country_is_in_india = yes
	#			}
	#		}
	#		set_global_variable = selon_treaty_void
	#	}
	#}
}

# Root = journal entry
on_journal_entry_activated = {
	effect = {
		post_notification = journal_entry_activated
	}
}

# Root = journal entry
on_journal_entry_deactivated = {
	effect = {
		post_notification = journal_entry_deactivated
	}
}

# Root = journal entry
on_journal_entry_completed = {
	effect = {
		post_notification = journal_entry_completed
	}
}

# Root = journal entry
on_journal_entry_failed = {

}


# Root = country
on_native_uprising = {
	effect = {
		post_notification = native_uprising_notification
	}
}

# Root = state
on_state_incorporation = {
	effect = {
		
	}
}

# Root = political movement
on_political_movement_formed = {
	effect = {
		post_notification = political_movement_formed
	}
}

# Root = political movement
on_political_movement_disbanded = {
	effect = {
		post_notification = political_movement_disbanded
	}
}

# Root = Colony state
on_colony_created = {
	effect = {
		owner = {
			if = {
				limit = {
					has_journal_entry = je_tutorial_colonize_state
				}
				root = {
					set_variable = {
						name = tut_colony_target
					}
				}
			}
		}
	}
}

# Root = Strategic Region
# scope:actor = Aggressor country
# scope:target = Target country
on_diplomatic_incident = {
	effect = {
		
	}
}

# Root = Objective
on_sub_objective_completed = {
}

# Root = Objective
on_sub_objective_failed = {
}

# Root = Objective
on_objective_completed = {
	effect = {
		debug_log = "Objective completed"
	}
}

# Root = Country
# scope:target = Party created
on_party_created = {
	effect = {
		debug_log = "[SCOPE.sParty('target').GetNameNoFormatting] Created"
	}
}

# Root = Country
# scope:target = Party disbanded
on_party_disbanded = {
	effect = {
		debug_log = "[SCOPE.sParty('target').GetNameNoFormatting] Disbanded"
	}
}

# Root = Country
on_election_campaign_start = {
	effect = {
		debug_log = "Election Campaign Started"
	}
}

# Root = Country
on_election_campaign_end = {
	effect = {
		debug_log = "Election Campaign Ended"
	}
}

# Root = Country
on_obligation_owed_by_us_expired = {
	effect = {
		post_notification = obligation_owed_by_us_expired
	}
}

# Root = Country
on_obligation_owed_to_us_expired = {
	effect = {
		post_notification = obligation_owed_to_us_expired
	}
}

# Root = Country
on_start_supporting_unification = {
	effect = {
		post_notification = start_supporting_unification
	}
}

# Root = Country
on_unification_candidate_added = {
	effect = {
		post_notification = unification_candidate_added
	}
}

# Root = Country
on_unification_candidate_removed = {
	effect = {
		post_notification = unification_candidate_removed
	}
}

# Root = Country
on_stop_supporting_unification = {
	effect = {
		post_notification = stop_supporting_unification
	}
}

# Root = Character
on_enemy_convoys_raided = {
	effect = {
		post_notification = enemy_convoys_raided
	}
}

# Root = Character
on_our_convoys_raided = {
	effect = {
		post_notification = our_convoys_raided
	}
}

# Root = Country
on_repudiate_obligation = {
	effect = {
		scope:target_country = {
			change_relations = { country = root value = -50 }
			hidden_effect = {
				random_list = {
					50 = {
						if = {
							limit = {
								country_rank > root.country_rank
							}
							set_secret_goal = {
								country = root
								secret_goal = dominate
							}								
						}
						else = {
							set_secret_goal = {
								country = root
								secret_goal = antagonize
							}							
						}				
					}
					50 = {}
				}
			}		
		}
		every_country = {
			limit = { 
				NOT = { this = scope:target_country }
				root = { owes_obligation_to = prev } 
			}
			change_relations = { country = root value = -30 }
			hidden_effect = {
				random_list = {
					25 = {
						if = {
							limit = {
								country_rank > root.country_rank
							}
							set_secret_goal = {
								country = root
								secret_goal = dominate
							}								
						}
						else = {
							set_secret_goal = {
								country = root
								secret_goal = antagonize
							}							
						}					
					}
					75 = {}
				}
			}
		}		
		hidden_effect = { # Should not stack the modifier
			if = { 
				limit = { has_modifier = repudiated_obligation } 
				remove_modifier = repudiated_obligation
			}			
		}
		add_modifier = {
			name = repudiated_obligation
			months = normal_modifier_time
			is_decaying = yes			
		}		
	}
}

# Root = Character
on_character_recruitment = {
	effect = {
		owner = {
			if = {
				limit = {
					has_journal_entry = je_tutorial_recruit_promote_commander
					# TODO PRCAL-22740
					# je:je_tutorial_recruit_promote_commander = {
					#	NOT = {
					#		has_variable = tut_commander_target
					#	}
					# }
				}
				je:je_tutorial_recruit_promote_commander = {
					set_variable = {
						name = tut_commander_target
						value = root
					}
					set_variable = {
						name = tut_commander_target_initial_rank
						value = root.commander_rank
					}
				}
			}
		}
	}
}

# Root = invaded country
# scope:actor = invading country
# scope:admiral = invading admiral
# scope:general = invading general
# scope:state = location state
on_naval_invasion = {
    effect = {
        post_notification = naval_invasion_against_us
    }
}